package kr.bae.androidcomplete01.chapter08;

import kr.bae.androidcomplete01.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class LongClick extends Activity{
	int mCount = 0;
	TextView tv;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.longclick);
		
		tv = (TextView) findViewById(R.id.count);
		findViewById(R.id.decrease).setOnLongClickListener(mLongClickListener);
		findViewById(R.id.increase).setOnLongClickListener(mLongClickListener);
	}
	
	public void mOnClick(View v) {
		switch (v.getId()) {
		case R.id.decrease:
			mCount--;
			tv.setText("" + mCount);
			break;
		case R.id.increase:
			mCount++;
			tv.setText("" + mCount);

		default:
			break;
		}
	}
	
	View.OnLongClickListener mLongClickListener = new View.OnLongClickListener() {
		
		@Override
		public boolean onLongClick(View v) {
			switch (v.getId()) {
			case R.id.decrease:
				mCount = 0;
				tv.setText("" + mCount);
				return true;
				
			case R.id.increase:
				mCount = 100;
				tv.setText("" + mCount);
				return true;

			default:
				break;
			}
			return false;
		}
	};
}
